<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="query.name" size="small" clearable placeholder="输入医院名称搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-input v-model="query.code" size="small" clearable placeholder="输入医院代码搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation />
      </div>
      <crudOperation :permission="permission" />
    </div>
    <!-- 医院表格 -->
    <el-table ref="table" v-loading="crud.loading" highlight-current-row style="width: 100%;" :data="crud.data" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
      <el-table-column :selectable="checkboxT" type="selection" width="55" />
      <el-table-column show-overflow-tooltip prop="name" label="医院名称" />
      <el-table-column show-overflow-tooltip prop="dataScope" label="医院代码" />
      <el-table-column prop="level" label="医院类型" />
      <el-table-column prop="level" label="是否能支付" />
      <el-table-column prop="level" label="医保开通" />
      <el-table-column prop="level" label="账单循环条数" />
      <el-table-column v-if="checkPer(['admin','roles:edit','roles:del'])" label="操作" width="130px" align="center" fixed="right">
        <template slot-scope="scope">
          <udOperation v-if="scope.row.level >= level" :data="scope.row" :permission="permission"/>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'

const defaultForm = { id: null, name: null, depts: [], description: null, dataScope: '全部', level: 3 }
  export default {
    name: 'Department',
    components: { crudOperation, rrOperation, udOperation },
    cruds() {
      return CRUD({ title: '科室', url: 'api/wechatDepart' })
    },
    mixins: [presenter(), header(), form(defaultForm), crud()],
    data() {
      return {
        permission: {
          add: ['admin', 'app:add'],
          edit: ['admin', 'app:edit'],
          del: ['admin', 'app:del']
        }
      }
    },
    methods: {
      checkboxT(row) {
        return row.level >= this.level
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>
